/*
 * CS 567 GUI - Semester Project - "DecisionLists"
 * Jason Frank
 * Spring 2011
 *
 * This File:  Implements the Butterfly View.
 */

package Decision_Lists;

import Decision_Lists.List_Item_Data.ProCon;
import java.awt.event.ActionEvent;
import javax.swing.*;
import java.awt.*;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.lang.reflect.Array;
import java.util.LinkedList;
import java.util.List;
import java.util.TreeMap;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.border.EtchedBorder;
import javax.swing.JLabel;

/*
 */
public class ButterflyView2 extends JPanel implements DL_ViewInterface {
//public class ButterflyView2 extends Panel_Fader_User implements DL_ViewInterface {

  ////////////////////////////////////////////////
  ///// Class Vars ///////////////////////////////
  protected boolean is_center_view = true;
  protected DL_Model model;
  protected TreeMap <String, List_Item_Data> items_map; // ptr for model's map of items_map
  protected Vector  <List_Item_Data> items_vec;
  protected int items_mod_num = 0;   // the # to mod with the size of the vec for a circular vec
  protected List_Item_Data currentItem;
  // the next list item to be displayed in this panel upon "prev" or "next" btn click:
  protected List_Item_Data nextItem;    
  protected final String view_name = "Butterfly";
  //protected int panelWidthPref  = 825;
  protected int panelWidthPref  = 1125;
  protected int panelHeightPref = 675;
  protected Dimension prevNextPanelDimension = new Dimension(62, 200);
//  protected Color panel_BG_color = new Color(240,240,240); // nearly white
  // Containers
  JPanel mainPanel = new JPanel();  // The panel of the main butterfly (not Prev/Next panel, etc)
  JPanel prevNextPanel = new JPanel(); // Make a panel for Prev & Next btns
  // <editor-fold defaultstate="collapsed" desc="class vars now in nested class">
  /*
  Box mainBox = Box.createHorizontalBox(); // Holds the main vertical columns of the butterfly
  Box prosVertBox = Box.createVerticalBox();
  Box consVertBox = Box.createVerticalBox();
  Box centerVertBox = Box.createVerticalBox();

  protected Butterfly_Center centerWidget;
  protected int centerWidgetWidth  = 330;
  protected int centerWidgetHeight = 310;
  //int centerWidgetHeight = 240;

  List <ProConPanel> proPanels = new LinkedList<ProConPanel>();
  List <ProConPanel> conPanels = new LinkedList<ProConPanel>();

  protected JLabel proLabel = new JLabel();
  protected JLabel conLabel = new JLabel();
  protected Font proLabelFont = new Font("Helvetica", Font.BOLD,  19);
  protected JPanel proLabelPanel = new JPanel();// For putting the proLabel into: addint the label
  // to a panel makes better layout amongst other panels
  protected JPanel conLabelPanel = new JPanel();
  protected Color prosLabelColor = new Color(80, 200, 70);  // R,G,B. So its Green-ish.
  protected Color consLabelColor = new Color(200, 70, 60);  // R,G,B. So its Red-ish.

  protected int centerPanelShiftDown;  // # pixels to shift it down to account for "Pros/Cons" labels.
  protected final int consColumnTopPad = 16;
  protected final int prosColumnTopPad = 16;

  protected int lineXCenterLeft;
  protected int lineXCenterRight;
  protected int lineYCenter;
  protected BasicStroke lineStroke = new BasicStroke(3);
  protected Color lineColor = new Color(120,120,120); // gray
   */// </editor-fold>
  // Prev/Next links
  protected JButton prevItemBtn = new JButton("Prev Item");
  protected JButton nextItemBtn = new JButton("Next Item");

  protected mainButterflyPanel current_main_panel;
  protected mainButterflyPanel next_main_panel;

  protected mainTargetPanel main_panel_containter; // holds current_main_panel, for panel-fading
  //// end Class vars /////
  /////////////////////////

  /////////////////////
  // Constructor
  public ButterflyView2(DL_Model model) throws Exception {
    
    this.model = model;           // link the model to this view
    this.model.addObserver(this, this.view_name, is_center_view); // link this view to the model
    this.items_map = model.getItemsMap();
    this.items_vec = model.getItemsVec();

    currentItem = items_vec.elementAt(items_mod_num); // using the mod num so we can iterate circularly

    // The panel that lays out the data of a list item
    current_main_panel = new mainButterflyPanel(currentItem);
    next_main_panel    = new mainButterflyPanel(); // need to set it's main item later

    // The panel that uses Panel_Fader to crossfade between list items_map
    main_panel_containter = new mainTargetPanel(current_main_panel);
    
    initVisibleComponents();

    addPrevNextEventHandlers();

    layoutEntireView();
  
  } ////////// end constructor /////////////


  protected void addPrevNextEventHandlers() {
  // <editor-fold defaultstate="collapsed" desc="method contents">
  // Setup handler for "Next Item" Btn click
    nextItemBtn.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        nextItem = model.getCircularNextItem(++items_mod_num);
        System.out.println("\nThe next list item was retrieved: " + nextItem.getName());

        next_main_panel = new mainButterflyPanel(nextItem);

        // Initiate the fade to the next panel
        try {
          // temp: trying to force the repaint by modifying a temp rect to be drawn
          //main_panel_containter.setColorVal( (int)(Math.random() * 1000));
          //main_panel_containter.setTestRectY( (int)(Math.random() *1000) % 300);
          main_panel_containter.fadeTo(next_main_panel);
        } catch (Exception ex) {
          Logger.getLogger(ButterflyView2.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    });

    // Setup handler for "Prev Item" Btn click
    prevItemBtn.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {

        nextItem = model.getCircularPrevItem(--items_mod_num);
        System.out.println("\nThe prev list item was retrieved: " + nextItem.getName());

        next_main_panel = new mainButterflyPanel(nextItem);

        // Initiate the fade to the next panel
        try {
          main_panel_containter.fadeTo(next_main_panel);
        } catch (Exception ex) {
          Logger.getLogger(ButterflyView2.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    });// </editor-fold>
    
  } //////////// end addPrevNextEventHandlers() ////////////

  

  // Initializes (and instantiates for some) visible components in prep of being layed-out
  protected void initVisibleComponents() {
    // <editor-fold defaultstate="collapsed" desc="method contents...">
    // Prev/Next Btns: set them up to look like JLabels (http://stackoverflow.com/questions/3025320/draw-a-jbutton-to-look-like-a-jlabel-or-at-least-without-the-button-edge)
    prevItemBtn.setMargin(new Insets(0, 0, 0, 0));
    prevItemBtn.setContentAreaFilled(false);
    prevItemBtn.setBorderPainted(false);
    prevItemBtn.setOpaque(false);
    nextItemBtn.setMargin(new Insets(0, 0, 0, 0));
    nextItemBtn.setContentAreaFilled(false);
    nextItemBtn.setBorderPainted(false);
    nextItemBtn.setOpaque(false);
    // <editor-fold defaultstate="collapsed" desc="code now in nested class">
    /*
    // Instantiate the Center Panel
    //centerWidget = new Butterfly_Center(model, centerWidgetWidth, centerWidgetHeight, panel_BG_color);
    centerWidget = new Butterfly_Center(currentItem, centerWidgetWidth, centerWidgetHeight,
    panel_BG_color);
    
    // Pro/Con Labels: Set the font and other properties
    proLabel.setFont(proLabelFont);
    proLabel.setText("<html><u>Pros</u></html>"); // add underlining.
    proLabelPanel.add(proLabel);  // add the label to a panel for better layout amongst other panels
    conLabel.setFont(proLabelFont); // reusing pro label font
    conLabel.setText("<html><u>Cons</u></html>");
    conLabelPanel.add(conLabel);
    proLabel.setForeground(prosLabelColor);
    conLabel.setForeground(consLabelColor);
    centerPanelShiftDown = getFontMetrics(proLabelFont).getHeight() + prosColumnTopPad;
    
    // Instantiate all the PRO and CON PANELS for this list item
    for (ProCon pro : currentItem.getPros()) {
    ProConPanel proPanel = new ProConPanel(pro, panel_BG_color);
    proPanels.add(proPanel);
    }
    for (ProCon con : currentItem.getCons()) {
    ProConPanel conPanel = new ProConPanel(con, panel_BG_color);
    conPanels.add(conPanel);
    }
    
    setBackground(panel_BG_color);
     */// </editor-fold>
    // </editor-fold>
  } ///////// end initVisibleComponents() /////


  // layoutEntireView()
  protected void layoutEntireView() {
    //////////////////////////////////////////////// // <editor-fold defaultstate="collapsed" desc="method contents...">
    //// LAYOUT and visual stuff ///////////////////

    // Setup the panel for Prev & Next btns
    prevNextPanel.add(prevItemBtn);
    prevNextPanel.add(nextItemBtn);
    prevNextPanel.setSize(prevNextPanelDimension);
    prevNextPanel.setMaximumSize(prevNextPanelDimension);
    prevNextPanel.setPreferredSize(prevNextPanelDimension);

    // BorderLayout so the Prev/Next btns can be placed to the side, etc.
    setLayout(new BorderLayout());

    // <editor-fold defaultstate="collapsed" desc="code now in nested class">
    /*
    // Make main panel non-opaque so that the drawn lines show through
    mainPanel.setOpaque(false);

    //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // BorderLayout so the Prev/Next btns can be placed to the side, etc.
    setLayout(new BorderLayout());

    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    //// LAYOUT MAIN HORIZ BOX ////
    mainBox.add(Box.createHorizontalGlue());  // Left SIDE padding
    ////  ADD COLUMN OF CONS ////
    // First add the "Cons" Label
    consVertBox.add(Box.createRigidArea(new Dimension(0, consColumnTopPad)));
    //consVertBox.add(Box.createVerticalGlue());
    consVertBox.add(conLabelPanel);
    // Next add all the cons panels
    for (ProConPanel conPanel : conPanels) {
    consVertBox.add(Box.createVerticalGlue());
    consVertBox.add(conPanel);
    }
    consVertBox.add(Box.createVerticalGlue());
    // Now add the entire column to the mainBox
    mainBox.add(consVertBox);

    //// Add CENTER PANEL /////
    mainBox.add(Box.createHorizontalGlue());  // Left SIDE of center panel padding
    //centerVertBox.add(Box.createRigidArea(new Dimension(0, centerPanelShiftDown)));
    //centerVertBox.add(Box.createRigidArea(new Dimension(0, 50)));
    centerVertBox.add(Box.createVerticalGlue());  // Top of Center Panel padding
    centerVertBox.add(Box.createVerticalGlue());
    centerVertBox.add(Box.createVerticalGlue());
    centerVertBox.add(centerWidget);
    centerVertBox.add(Box.createVerticalGlue());  // Bottom of Center Panel padding
    centerVertBox.add(Box.createVerticalGlue());
    mainBox.add(centerVertBox);
    mainBox.add(Box.createHorizontalGlue()); // Right SIDE of center panel padding

    ////  ADD COLUMN OF PROS ////
    // First add the "Pros" Label
    prosVertBox.add(Box.createRigidArea(new Dimension(0, prosColumnTopPad)));
    prosVertBox.add(proLabelPanel);
    // Next add all the pros panels
    for (ProConPanel proConPanel : proPanels) {
    prosVertBox.add(Box.createVerticalGlue());
    prosVertBox.add(proConPanel);
    }
    prosVertBox.add(Box.createVerticalGlue());
    // Now add the entire column to the mainBox
    mainBox.add(prosVertBox);


    mainBox.add(Box.createHorizontalGlue()); // Right SIDE padding

    mainPanel.add(Box.createVerticalGlue());  // Used to vertically center the mainBox
    mainPanel.add(mainBox);
    mainPanel.add(Box.createVerticalGlue());
     */// </editor-fold>

    // The Panel_Fader obj should have added the current panel to "mainPanel", so just adding it to this outer
    //  class's center should work.
          //add(mainPanel, BorderLayout.CENTER);
    add(main_panel_containter, BorderLayout.CENTER);
    // Put Prev & Next Btns on far right
    add(prevNextPanel, BorderLayout.LINE_END);// </editor-fold>
  } /////////// end layoutEntireView() ////////


  ////////////////////////////////////////////////////
  /// NESTED CLASS:  mainTargetPanel - the container that holds "current" mainButterflyPanel
  ///                 useful for transitioning from "current" to "next" list item
  protected class mainTargetPanel extends Panel_Fader_User {

    mainButterflyPanel current_main_panel;
    

    // Constructor
    public mainTargetPanel(mainButterflyPanel current_main_panel ) throws Exception {

      this.current_main_panel = current_main_panel;

      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
              // Trying to set layout (again I think) a diff way trying to get the fade to work (found out with the South pane...)
              //this.current_main_panel.setLayout(new BoxLayout(this.current_main_panel, BoxLayout.X_AXIS));

      // The panel-fader mechanism will add current_main_panel to this obj's layout
      super.init_PanelFaderUser(this, current_main_panel);  // args: target_panel, current_panel
      // Setting the fade timer intervals quick for now
      pf3.setFadeout_interval_miliseconds(3);
      pf3.setFadein_interval_miliseconds(3);
    }

    
    public void fadeTo(mainButterflyPanel next_panel) throws Exception {

              // Trying to set layout (again I think) a diff way trying to get the fade to work (found out with the South pane...)      //
              //next_panel.setLayout(new BoxLayout(next_panel, BoxLayout.X_AXIS));

      pf3.setFadein_panel(next_panel);
      try {
        pf3.startFade();
      } catch (Exception ex) {
          Logger.getLogger(CenterPanel3.class.getName()).log(Level.SEVERE, null, ex);
      }
     
    } //// end fadeTo() ///


    // Trying to get the superclass's paintComponent to actually be called (in case it thinks the panel has size 0
    @Override
    public Dimension getMinimumSize()   { return getPreferredSize(); }
    @Override
    public Dimension getPreferredSize() {
      return new Dimension(panelWidthPref - prevNextPanelDimension.width, panelHeightPref);
    }
    
  }
  ///// end Nested Class mainTargetPanel ////////////
  ///////////////////////////////////////////////////

  ////////////////////////////////////////////////////
  /// NESTED CLASS:  mainButterflyPanel - the main panel - not the Next/Prev stuff on right
  protected class mainButterflyPanel extends JPanel {

    List_Item_Data item;  // the list item to be used for this class's data
    protected Color panel_BG_color = new Color(240,240,240); // nearly white
    // Containers
    JPanel mainContainerPanel = new JPanel();
    Box mainBox = Box.createHorizontalBox(); // Holds the main vertical columns of the butterfly
    Box prosVertBox = Box.createVerticalBox();
    Box consVertBox = Box.createVerticalBox();
    Box centerVertBox = Box.createVerticalBox();

    protected Butterfly_Center centerWidget;
    protected int centerWidgetWidth  = 330;
    protected int centerWidgetHeight = 310;
        //int centerWidgetHeight = 240;

    List <ProConPanel> proPanels = new LinkedList<ProConPanel>();
    List <ProConPanel> conPanels = new LinkedList<ProConPanel>();

    protected JLabel proLabel = new JLabel();
    protected JLabel conLabel = new JLabel();
    protected Font proLabelFont = new Font("Helvetica", Font.BOLD,  19);
    protected JPanel proLabelPanel = new JPanel();// For putting the proLabel into: addint the label
                                                  // to a panel makes better layout amongst other panels
    protected JPanel conLabelPanel = new JPanel();
    protected Color prosLabelColor = new Color(80, 200, 70);  // R,G,B. So its Green-ish.
    protected Color consLabelColor = new Color(200, 70, 60);  // R,G,B. So its Red-ish.

    protected int centerPanelShiftDown;  // # pixels to shift it down to account for "Pros/Cons" labels.
    //protected final int consColumnTopPad = 16;
    //protected final int prosColumnTopPad = 16;
    protected final int consColumnTopPad = -10; // negative to force cols of pros/cons upward (to lesson the topmost vert glue's added spacing)
    protected final int prosColumnTopPad = -10;

    protected int lineXCenterLeft;
    protected int lineXCenterRight;
    protected int lineYCenter;
    protected BasicStroke lineStroke = new BasicStroke(3);
    protected Color lineColor = new Color(120,120,120); // gray
    //// end nested class vars ////
    ///////////////////////////////

    // Constructor #1
    public mainButterflyPanel(List_Item_Data item) {
      this.item = item;
      
      initVisibleComponents();
      layoutEntirePanel();
    } ///////// end nested class constructor ////

    // Constructor #2
    public mainButterflyPanel() {


    } ///////// end nested class constructor ////

    // Initializes (and instantiates for some) visible components in prep of being layed-out
    protected void initVisibleComponents() {

      // Instantiate the Center Panel
      //centerWidget = new Butterfly_Center(model, centerWidgetWidth, centerWidgetHeight, panel_BG_color);
      centerWidget = new Butterfly_Center(item, centerWidgetWidth, centerWidgetHeight,
              panel_BG_color);

      // Pro/Con Labels: Set the font and other properties
      proLabel.setFont(proLabelFont);
      proLabel.setText("<html><u>Pros</u></html>"); // add underlining.
      proLabelPanel.add(proLabel);  // add the label to a panel for better layout amongst other panels
      conLabel.setFont(proLabelFont); // reusing pro label font
      conLabel.setText("<html><u>Cons</u></html>");
      conLabelPanel.add(conLabel);
      proLabel.setForeground(prosLabelColor);
      conLabel.setForeground(consLabelColor);
      centerPanelShiftDown = getFontMetrics(proLabelFont).getHeight() + prosColumnTopPad;

      // Instantiate all the PRO and CON PANELS for this list item
      for (ProCon pro : item.getPros()) {
        ProConPanel proPanel = new ProConPanel(pro, panel_BG_color);
        proPanels.add(proPanel);
      }
      for (ProCon con : item.getCons()) {
        ProConPanel conPanel = new ProConPanel(con, panel_BG_color);
        conPanels.add(conPanel);
      }

      setBackground(panel_BG_color);// </editor-fold>
    } ///////// end initVisibleComponents() /////

    
    // layoutEntirePanel()
    protected void layoutEntirePanel() {
      //////////////////////////////////////////////// // <editor-fold defaultstate="collapsed" desc="method contents...">
      //// LAYOUT and visual stuff ///////////////////
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

      // Make main panel non-opaque so that the drawn lines show through
      mainContainerPanel.setOpaque(false);

      mainContainerPanel.setLayout(new BoxLayout(mainContainerPanel, BoxLayout.Y_AXIS));
      //// LAYOUT MAIN HORIZ BOX ////
      mainBox.add(Box.createHorizontalGlue());  // Left SIDE padding
      ////  ADD COLUMN OF CONS ////
      // First add the "Cons" Label
      consVertBox.add(Box.createRigidArea(new Dimension(0, consColumnTopPad)));
      //consVertBox.add(Box.createVerticalGlue());
      consVertBox.add(conLabelPanel);
      // Next add all the cons panels
      for (ProConPanel conPanel : conPanels) {
        consVertBox.add(Box.createVerticalGlue());
        consVertBox.add(conPanel);
      }
      consVertBox.add(Box.createVerticalGlue());
      // Now add the entire column to the mainBox
      mainBox.add(consVertBox);

      //// Add CENTER PANEL /////
      mainBox.add(Box.createHorizontalGlue());  // Left SIDE of center panel padding
      //centerVertBox.add(Box.createRigidArea(new Dimension(0, centerPanelShiftDown)));
      //centerVertBox.add(Box.createRigidArea(new Dimension(0, 50)));
      centerVertBox.add(Box.createVerticalGlue());  // Top of Center Panel padding
      centerVertBox.add(Box.createVerticalGlue());
      centerVertBox.add(Box.createVerticalGlue());
      centerVertBox.add(centerWidget);
      centerVertBox.add(Box.createVerticalGlue());  // Bottom of Center Panel padding
      centerVertBox.add(Box.createVerticalGlue());
      mainBox.add(centerVertBox);
      mainBox.add(Box.createHorizontalGlue()); // Right SIDE of center panel padding

      ////  ADD COLUMN OF PROS ////
      // First add the "Pros" Label
      prosVertBox.add(Box.createRigidArea(new Dimension(0, prosColumnTopPad)));
      prosVertBox.add(proLabelPanel);
      // Next add all the pros panels
      for (ProConPanel proConPanel : proPanels) {
        prosVertBox.add(Box.createVerticalGlue());
        prosVertBox.add(proConPanel);
      }
      prosVertBox.add(Box.createVerticalGlue());
      // Now add the entire column to the mainBox
      mainBox.add(prosVertBox);


      mainBox.add(Box.createHorizontalGlue()); // Right SIDE padding

      mainContainerPanel.add(Box.createVerticalGlue());  // Used to vertically center the mainBox
      mainContainerPanel.add(mainBox);
      mainContainerPanel.add(Box.createVerticalGlue());

      add(mainContainerPanel);  // </editor-fold>

    }  ////////// end layoutEntirePanel() ////////////



    // Draws the Lines that connect the center widget to the pro/con panels
    @Override
    public void paintComponent(Graphics g) {
      // <editor-fold defaultstate="collapsed" desc="method contents">
      // Call the superclass paintComponent() to clear the clipping region (avoids ghosting).
      super.paintComponent(g);
      // make a deep copy of the Graphics object before modifying it
      Graphics myG = g.create();
      Graphics2D g2 = (Graphics2D) myG;
      setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

      //////////////////////////////
      //// DRAW LINES //////////////
      initDrawVars();
      g2.setStroke(lineStroke);
      g2.setColor(lineColor);
      int conXEnd = mainContainerPanel.getWidth() / 4;
      // Cons lines
      for (int i = 1; i <= conPanels.size(); i++) {
        g2.drawLine(lineXCenterLeft, lineYCenter,
                conXEnd, (((mainContainerPanel.getHeight() / (conPanels.size() + 1)) + 0) * i));
      }

      int proXEnd = mainContainerPanel.getWidth() * 3 / 4;
      // Pros lines
      for (int i = 1; i <= proPanels.size(); i++) {
        g2.drawLine(lineXCenterRight, lineYCenter,
                proXEnd, (((mainContainerPanel.getHeight() / (proPanels.size() + 1)) + 0) * i));
      }

      // clear up resources
      myG.dispose();// </editor-fold>
    } ///// end paintComponent() ///

    private void initDrawVars() {
      lineXCenterLeft  = mainContainerPanel.getWidth() / 2;
      lineXCenterRight = mainContainerPanel.getWidth() / 2;
      lineYCenter      = (int) ((int) (mainContainerPanel.getHeight() / 2)); // + ((double) mainContainerPanel.getHeight() * .1));

    } /////// end initDrawVars() ////////

    ///////////////////////////////////
    ////// GETTERS AND SETTERS ////////

    public void setItem(List_Item_Data item) {
      this.item = item;
      // Now basically do what a constructor would do since we have a (potentially new) list item
      initVisibleComponents();
      removeAll();  // remove any objects that may have been layed-out for a diff list item
      layoutEntirePanel();
    }

    //// end Getters and Setters ////
    /////////////////////////////////

    @Override
    public Dimension getMinimumSize()   { return getPreferredSize(); }
    @Override
    public Dimension getPreferredSize() { 
      return new Dimension(panelWidthPref - prevNextPanelDimension.width, panelHeightPref);
    }
    
  }
  ///// end Nested Class mainButterflyPanel ////////////
  //////////////////////////////////////////////////////


  /////////////////////////////////////////////////
  ////// Methods Required by the Interface ////////

  // the Model calls this to notify this View of a changed current value
  public void curViewChanged(String old_view_name, String new_view_name) {
    if( old_view_name.equals(this.view_name) ) {
      // TODO: change this
      repaint();  // zero-arg verion of repaint() repaints entire contentPane      
    }
    if( new_view_name.equals(this.view_name)) {
    }
    
  } ////// end curViewChanged() /////////

  // Model calls this to inform views of an added (new) list item.
  //  The views will then probably need to re-layout their list items to reflect the change.
  public void itemAdded(List_Item_Data newItem) {
    // Do nothing
  }
  // Model calls this to inform views of a changed list item (i.e., new item added, old item deleted, etc).
  //  The views will then probably need to re-layout their list items to reflect the change.
  public void itemChanged() {
    // Do nothing
  }

  public String getViewName() {
    return this.view_name;
  } ////

  /////// end required by interface functions  //////
  ///////////////////////////////////////////////////



  @Override
  public Dimension getMinimumSize()   { return new Dimension(panelWidthPref - 300,
                                                             panelHeightPref -300); }
  @Override
  public Dimension getPreferredSize() { return new Dimension(panelWidthPref, panelHeightPref); }
  
} ////////// end class ButterflyView //////////////////////////
